const { spawn } = require("child_process");
const os = require("os");

const isWindows = os.platform() === "win32";

const command = isWindows ? "set" : "export";
const env = Object.assign({}, process.env, {
  NODE_ENV: process.argv[2] || "development",
});

const nodemon = spawn("nodemon", ["bin/www"], {
  stdio: "inherit",
  shell: true,
  env,
});

nodemon.on("error", (err) => {
  console.error("Failed to start nodemon:", err);
});
